﻿Imports System.Configuration

Namespace Connection

    ''' <summary>
    ''' 環境要素コレクション
    ''' </summary>
    ''' <remarks></remarks>
    Public Class DatabaseElementCollection
        Inherits ConfigurationElementCollection

        Public Sub New()
            MyBase.AddElementName = "database"
        End Sub

        ''' <summary>
        ''' 要素を取得します。
        ''' </summary>
        Public Function GetDatabase(ByVal name As String) As DatabaseElement
            Return DirectCast(MyBase.BaseGet(name), DatabaseElement)
        End Function

        ''' <summary>
        ''' 新しい要素を作成します。
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Protected Overloads Overrides Function CreateNewElement() As System.Configuration.ConfigurationElement
            Return New DatabaseElement
        End Function

        Protected Overrides Function GetElementKey(ByVal element As System.Configuration.ConfigurationElement) As Object
            Dim el As DatabaseElement = TryCast(element, DatabaseElement)
            If el Is Nothing Then Return Nothing
            Return el.Name
        End Function
    End Class

End Namespace
